﻿@model PagedList.IPagedList<HdipCricketClub.Models.Opponent>

@{
    ViewBag.Title = "Opponents:";
}

<h2>@ViewBag.Title</h2>

@using (@Html.BeginForm())
{
    <p>
    Find by Club Name: @Html.TextBox("searchString")
    <input type="submit" value="Search" />
    </p>
}

<table>
    <tr>
        <th>
            Club:
        </th>
        <th>
            Team:
        </th>
        <th>
            Address:
        </th>
        <th>
            Phone:
        </th>
        <th>
            E mail:
        </th>
        <th>
            Contact:
        </th>
     </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.club_name)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.team_name)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.address_1),
            @if (item.address_2 != null)
            {    
                @Html.DisplayFor(modelItem => item.address_2)@:,
            }
            @Html.DisplayFor(modelItem => item.town_city),
            @Html.DisplayFor(modelItem => item.county).
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.phone)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.email)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.contact_name)
        </td>
     </tr>
}

</table>
<br />
<div>
    Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber)
    of @Model.PageCount

    @if (Model.HasPreviousPage)
    {
        @Html.ActionLink("<<", "List", new { page = 1 })
        @Html.Raw(" ");
        @Html.ActionLink("< Prev", "List", new { page = Model.PageNumber - 1 })
    }
    else
    {
        @:<<
        @Html.Raw(" ");
        @:< Prev              
    }

    @if (Model.HasNextPage)
    {
        @Html.ActionLink("Next >", "List", new { page = Model.PageNumber + 1 })
        @Html.Raw(" ");
        @Html.ActionLink(">>", "List", new { page = Model.PageCount})
    }
    else
    {
        @:Next >
        @Html.Raw(" ");
        @:>>              
    }
</div>
<br />
<div>
        @Html.ActionLink("Return to Home Page", "Index", "Home")
</div>